package net.neptech.repository;

import net.neptech.entity.ConferenceParticipant;
import net.neptech.entity.vo.ParticipantVO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface ConferenceParticipantRepository extends JpaRepository<ConferenceParticipant, Long> {

    /**
     * 根据会议ID查询所有参与者
     */
    List<ConferenceParticipant> findByConferenceId(String conferenceId);

    /**
     * 可选：返回 VO 类型（需配合构造函数）
     */
    @Query("SELECT new net.neptech.entity.vo.ParticipantVO(p.userId, p.userName, p.joinedAt) " +
            "FROM ConferenceParticipant p WHERE p.conferenceId = :conferenceId")
    List<ParticipantVO> findParticipantVOsByConferenceId(@Param("conferenceId") String conferenceId);
}